'use strict';
var Schema = require('mongoose').Schema,
    Model = require('../../../Base/server/controllers/Model');

var modelField = {};

//条码主档
modelField.BarcodeMaster = {
    type: Schema.ObjectId,
    ref: 'BarcodeMaster'
};
//条码
modelField.Barcode = {
    type: String,
    trim: true
};

//提交APP
modelField.AppKey = {
    type: String,
    trim: true
};

//单据编码
modelField.DocCode={
    type: String,
    trim: true
};

//入库人
modelField.RcvUser={
    type: Schema.ObjectId,
    ref: 'User'
};
//入库时间
modelField.RcvDateTime={
    type: Date,
    default: Date.now
};

//U9生单单据类型：
//0，收货单；1，委外收货单；2，出货单；3，调出单；4，调入单
//5，杂发单；6，杂收单；7，盘点单；8，领料单；完工入库单；
modelField.DocType={
    type: Number,
    default: -1
};
//生单Json：
modelField.CreateDocJSON = {
    type: String,
    trim: true
};
modelField.CreateDocContextJSON ={
    type: String,
    trim: true
};

//已经生单
modelField.IsCreatedERPDoc={
    type: Boolean
};
//生单是否成功
modelField.IsSuccessCreatedErpDpc={
    type: Boolean
};
//生单失败原因
modelField.FailReason ={
    type: String,
    trim: true
};

//企业号
modelField.EntCode={
    type: String,
    trim: true
};
//组织编码
modelField.OrgCode={
    type: String,
    trim: true
};
modelField.CultureName={
    type: String,
    trim: true
}

//异动类别： 0，收货； 1，发货
modelField.Direction={
    type:Number,
    default:0
};

//操作类别： 0，创建单据； 1，审核单据， 2：创建并审核单据
modelField.OperType={
    type:Number,
    default:0
};

//操作key:传Erp生单使用
modelField.OperationKey={
    type: String,
    trim: true
};

modelField.UserCode={
    type: String,
    trim: true
};

//来源单号
modelField.SourceDocNum={
    type: String,
    trim: true
};

//业务组织名称
modelField.BizOrgName={
    type: String,
    trim: true
};

//end-条码平台开发

var newModel = new Model(modelField);
newModel.addIndex({Barcode: 1});
newModel.addIndex({IsCreatedERPDoc: 1});
newModel.create('WhTrans', '出入库单据');